package javafxkillerguidemo;

import javafx.application.*;
import javafx.geometry.*;
import javafx.scene.paint.*;
import javafx.stage.*;
import javafx.scene.text .*;
import javafx.scene.image.*;
import javafx.scene.shape.*;
import razor.blade.*;
import javafx.beans.binding.*;
import javafx.event.*;
import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.stage.*;
import javafx.beans.property.*;
import javafx.beans.value.*;
import javafx.scene.image.*;
import javafx.scene.input.*;
import javafx.scene.shape.*;
import javafx.scene.text.*;
import javafx.geometry.*;
import tee.binding.*;
//import java.net.*;
//import javax.swing.*;
public class JavaFXKillerGUIDemo extends Application {
     public static void main(String[] args) {
        Application.launch(JavaFXKillerGUIDemo.class, args);
    }
    @Override public void start(Stage primaryStage) {
        UserProperties properties = new UserProperties("JavaFXKillerGUIDemo.txt");  
        String title="JavaFX mail";
        StageBuilder
            .create()
            .icons(new Image[]{
                new Image(this.getClass().getResourceAsStream("resources/32Mail-icon.png"))                
                })
            .title(title)
            .applyTo(primaryStage);
        ImageView v1 = new ImageView();
        ImageView v2 = new ImageView();
        ImageView v3 = new ImageView();
        ImageView v4 = new ImageView();
        v1.setImage(new Image(this.getClass().getResourceAsStream("resources/32Categories-applications-system-icon.png")));
        v2.setImage(new Image(this.getClass().getResourceAsStream("resources/32Actions-document-edit-icon.png")));
        v3.setImage(new Image(this.getClass().getResourceAsStream("resources/32Actions-mail-receive-icon.png")));
        v4.setImage(new Image(this.getClass().getResourceAsStream("resources/32Status-dialog-information-icon.png")));
	final DesktopX desktop = new DesktopX();
        Font titleFont= desktop.font(35);
		//Font.loadFont(this.getClass().getResourceAsStream("../razor/blade/12503.ttf"), 35);
        Text titleText=new Text(title);
        titleText.setTextOrigin(VPos.TOP);
        titleText.setFill(Color.web("#ffffff33"));
        titleText.setFont(titleFont);
        Lasso titleLasso=new Lasso().content(titleText);
        Anchor titleAnchor=new Anchor()
                .y(16)
                .x(properties.asNumeric("width", 600).minus(titleLasso.width()).divide(2))
                .content(titleLasso.node());
        ImageView bgView = new ImageView();
        bgView.setImage(new Image(this.getClass().getResourceAsStream("resources/512Mail-icon.png")));
        bgView.setX(-50);
        bgView.yProperty().bind(new Tee<Double>(properties.asNumeric("height", 600).minus(512-50)));
        bgView.setOpacity(0.1);
        Rectangle bgClip=new Rectangle();
        bgClip.widthProperty().bind(new Tee<Double>(properties.asNumeric("width", 600).minus(32)));
        bgClip.heightProperty().bind(new Tee<Double>(properties.asNumeric("height", 600).minus(32)));
        bgClip.setX(16);
        bgClip.setY(16);
        bgView.setClip(bgClip);
        Circle circle = new Circle();
circle.setCenterX(200.0f);
circle.setCenterY(200.0f);
circle.setRadius(200.0f);
circle.setFill(Color.web("00ff0022"));
        SimpleObjectProperty<Color>color=new SimpleObjectProperty<Color>(Color.web("#003366"));
        final Section ss=new Section();
	//SimpleDoubleProperty ytd=properties.asDouble("upDown", 300);
        desktop
           .messageBoxWidth(properties.asNumeric("messageBoxWidth", 400))
            .messageBoxHeight(properties.asNumeric("messageBoxHeight", 200))
            .messageBoxX(properties.asNumeric("messageBoxX", 100))
            .messageBoxY(properties.asNumeric("messageBoxY", 100))
            .color(color.get())
            .closeButtonPressed(new Task(){@Override public void doTask() {
                    System.exit(0);
                    }
                })
            .background(bgView)
            .background(titleAnchor.node())
            .item(new ScrapeHorizontal()                    
                    .x(16)
                    .y(16+80-16)
                    .width(properties.asNumeric("width", 600).minus(32))
                .node())
            .item(new ScrapeHorizontal()
                    .x(16)
                    .y(properties.asNumeric("height", 600).minus(16+19+16))
                    .width(properties.asNumeric("width", 600).minus(32))
                .node())
            .item(new ButtonBox()
		    .buttonPressed(new Task(){@Override public void doTask() {
			    ss.fold(!ss.fold().value());
			    }
			})
                    .x(16+20+50*0)
                    .y(16+30-16)
                    .height(50)
                    .width(50)
                    .color(color.get())
                    .content(v1)
                .node())
            .item(new ButtonBox()
                    .buttonPressed(new Task(){@Override public void doTask() {
                            desktop.warninig("Two");
                            }
                        })
                    .x(16+20+50*1)
                    .y(16+30-16)
                    .height(50)
                    .width(50)
                    .color(color.get())
                    .content(v2)
                .node())
            .item(new ButtonBox()
                    .buttonPressed(new Task(){@Override public void doTask() {
                            desktop.warninig("Three");
                            }
                        })
                    .x(16+20+50*2)
                    .y(16+30-16)
                    .height(50)
                    .width(50)
                    .color(color.get())
                    .content(v3)
                .node())
            .item(new ButtonBox()
                    .buttonPressed(new Task(){@Override public void doTask() {
                            desktop.warninig("Four");
                            }
                        })
                    .x(16+20+50*3)
                    .y(16+30-16)
                    .height(50)
                    .width(50)
                    .color(color.get())
                    .content(v4)
                .node())
            .item(new ScrollBox()
                .x(0)
                .y(98-16)
                .height(properties.asNumeric("height", 600).minus(133))
                .width(properties.asNumeric("leftRight", 200))
                .content(circle)
                .node())                  
            .item(ss
                .x(0)
                .y(98-16)
                .height(properties.asNumeric("height", 600).minus(133))
                .width(properties.asNumeric("leftRight", 200))
                .fold(false)
                .node())               
            /*.item(new ScrollVertical()
                .x(properties.asNumeric("leftRight", 200).minus(14))
                .y(16+80-16)
                .height(properties.asNumeric("height", 600).minus(80+32+20))
                .node()) */ 
            .item(new DataGrid()
                    .x(properties.asNumeric("leftRight", 200).plus(2))
                    .y(80+2)
                    .width(properties.asNumeric("width", 600).minus(properties.asNumeric("leftRight", 200)).minus(34))
                    .height(properties.asNumeric("upDown", 600).minus(82))
                .node())
            .item(new TowLeftRight()
                    .x(properties.asNumeric("leftRight", 200))
                    .y(80)
                    .height(properties.asNumeric("height", 600).minus(133))
                .node())
            .item(new TowUpDown()
                    .x(properties.asNumeric("leftRight", 200))
                    .y(properties.asNumeric("upDown", 300))
                    .width(properties.asNumeric("width", 600).minus(32).minus(properties.asNumeric("leftRight", 200)))
                .node())
            .startup(primaryStage);
        desktop.width(properties.asNumeric("width", 600));
        desktop.height(properties.asNumeric("height", 400));
        //desktop.x(properties.asDouble("x", 0));
        //desktop.y(properties.asDouble("y", 0));
	desktop.x().bind(properties.asNumeric("x", 0));
        desktop.y().bind(properties.asNumeric("y", 0));
	//test();
    }
    
}
